
/**
 * Created by 12433 on 2018/1/29.
 */
const CryptoJS = require('crypto-js');


export function encrypt (message) {
  var keyHex = CryptoJS.enc.Utf8.parse("0123456789abcd0123456789");
  var encrypted = CryptoJS.TripleDES.encrypt(message, keyHex, {
    vi:null,
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  });
  return encrypted.toString();
}

export function decrypt(ciphertext) {
  var keyHex = CryptoJS.enc.Utf8.parse("0123456789abcd0123456789");
  var decrypted = CryptoJS.TripleDES.decrypt({
    ciphertext: CryptoJS.enc.Base64.parse(ciphertext.yxw)
  }, keyHex, {
    vi:null,
    mode: CryptoJS.mode.ECB,
    padding: CryptoJS.pad.Pkcs7
  });
  return decrypted.toString(CryptoJS.enc.Utf8);
}



